pub mod lib;

use lib::*;

use std::rc::Rc;

fn main() {
    let mut m = vec![];
    for i in 1_u32..=9_u32 {
        m.push(MergeableHeapNodeT::build(i));
    }
    let mut ajc = vec![];
    ajc.push(NewAdjacencyListNode::build(
        Rc::clone(&m[0]),
        vec![(Rc::clone(&m[1]), 4), (Rc::clone(&m[7]), 8)],
    ));
    ajc.push(NewAdjacencyListNode::build(
        Rc::clone(&m[1]),
        vec![
            (Rc::clone(&m[0]), 4),
            (Rc::clone(&m[2]), 8),
            (Rc::clone(&m[7]), 11),
        ],
    ));
    ajc.push(NewAdjacencyListNode::build(
        Rc::clone(&m[2]),
        vec![
            (Rc::clone(&m[1]), 8),
            (Rc::clone(&m[3]), 7),
            (Rc::clone(&m[5]), 4),
            (Rc::clone(&m[8]), 2),
        ],
    ));

    ajc.push(NewAdjacencyListNode::build(
        Rc::clone(&m[3]),
        vec![
            (Rc::clone(&m[2]), 7),
            (Rc::clone(&m[4]), 9),
            (Rc::clone(&m[5]), 14),
        ],
    ));
    ajc.push(NewAdjacencyListNode::build(
        Rc::clone(&m[4]),
        vec![(Rc::clone(&m[3]), 9), (Rc::clone(&m[5]), 10)],
    ));
    ajc.push(NewAdjacencyListNode::build(
        Rc::clone(&m[5]),
        vec![
            (Rc::clone(&m[2]), 4),
            (Rc::clone(&m[3]), 14),
            (Rc::clone(&m[4]), 10),
            (Rc::clone(&m[6]), 2),
        ],
    ));

    ajc.push(NewAdjacencyListNode::build(
        Rc::clone(&m[6]),
        vec![
            (Rc::clone(&m[5]), 2),
            (Rc::clone(&m[7]), 1),
            (Rc::clone(&m[8]), 6),
        ],
    ));
    ajc.push(NewAdjacencyListNode::build(
        Rc::clone(&m[7]),
        vec![
            (Rc::clone(&m[0]), 8),
            (Rc::clone(&m[1]), 11),
            (Rc::clone(&m[6]), 1),
            (Rc::clone(&m[8]), 7),
        ],
    ));
    ajc.push(NewAdjacencyListNode::build(
        Rc::clone(&m[8]),
        vec![
            (Rc::clone(&m[2]), 2),
            (Rc::clone(&m[6]), 6),
            (Rc::clone(&m[7]), 7),
        ],
    ));

    let res = MinimumSpanningTreePrim::mst_prim(NewAdjacencyList::build(ajc), Rc::clone(&m[0]));
    println!("{:?}", res);
}
